
package com.dojotec.biblioteca.jsf.domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.SequenceGenerator;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

/**
 *
 * @author Alan Almeida
 */
@Entity
@Table(name = "emprestimo")
@NamedQueries({
    @NamedQuery(name = "Emprestimo.buscarTodos", query = "SELECT e FROM Emprestimo e"),
    @NamedQuery(name = "Emprestimo.buscarPorId", query = "SELECT e FROM Emprestimo e WHERE e.id = :id")
})
public class Emprestimo implements Serializable {
    @Id 
      @SequenceGenerator( name = "emprestimo_id", sequenceName = "emprestimo_seq", allocationSize = 1 )  
      @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "emprestimo_id" )
      @Column( name = "id", nullable = false )
    private Long id;
    @Column(name = "data_emprestimo", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataEmprestimo;
    @JoinColumn(name = "usuario_id", referencedColumnName = "id")
    @ManyToOne
    private Usuario usuario;

    public Emprestimo() {
        
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDataEmprestimo() {
        return dataEmprestimo;
    }

    public void setDataEmprestimo(Date dataEmprestimo) {
        this.dataEmprestimo = dataEmprestimo;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

}
